#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_INIT([skylistener], [0.2.2], [swhors@naver.com])
AC_PREREQ([2.59])
AM_INIT_AUTOMAKE([skylistener], [0.2.2])
AC_CONFIG_SRCDIR([src/config.cpp])
AC_CONFIG_HEADERS([inc/config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h memory.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h asterisk.h sql.h sqltypes.h sqlext.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL

#dnl Check if we're a little-endian or a big-endian system
AC_DEFUN([AC_C_ENDIAN],
[AC_CACHE_CHECK(for endianness, ac_cv_c_endian,
[
	AC_RUN_IFELSE(
		[AC_LANG_PROGRAM([],[dnl
			long val = 1;
			char *c = (char*) &val;
			exit( *c == 1 );
		])
	],[
		ac_cv_c_endian = big;
	],[
		ac_cv_c_endian = little;
	])
])
if test $ac_cv_c_endian = big; then
	AC_DEFINE(ENDIAN_BIG, 1, [machine is bigendian])
fi
if test $ac_cv_c_endian = little; then
	AC_DEFINE(ENDIAN_LITTLE,1, [machine is littleendian])
fi
])

AC_DEFINE(HAVE_SQL_H,1,[mysql])

# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MKTIME
AC_CHECK_FUNCS([bzero gethostbyname lchown memmove memset mkdir select socket strstr])
AC_CHECK_LIB([pthread],[main])
AC_CHECK_LIB([odbc],[main])

AC_CONFIG_FILES([Makefile
                 skycli/Makefile
                 skylistener/Makefile])
AC_OUTPUT
